<html>
<head><meta charset="utf-8"><title>lazy norm closures · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20closures.html">lazy norm closures</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223774505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20closures/near/223774505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20closures.html#223774505">(Jan 23 2021 at 20:46)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(lazy_normalization_consts)]</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nb">Box</span><span class="o">&lt;</span><span class="k">dyn</span><span class="w"> </span><span class="nb">Iterator</span><span class="o">&lt;</span><span class="n">Item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[();</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">|</span><span class="n">x</span>: <span class="kt">u32</span><span class="o">|</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="p">}]</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="nb">Box</span>::<span class="n">new</span><span class="p">(</span><span class="n">std</span>::<span class="n">iter</span>::<span class="n">empty</span><span class="p">())</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>causes</p>
<div class="codehilite"><pre><span></span><code>warning: cannot use constants which depend on generic parameters in types
 --&gt; src/lib.rs:4:16
  |
4 | fn foo&lt;T&gt;() -&gt; Box&lt;dyn Iterator&lt;Item = [(); { |x: u32| x; 4 }]&gt;&gt; {
  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(const_evaluatable_unchecked)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #76200 &lt;https://github.com/rust-lang/rust/issues/76200&gt;
</code></pre></div>



<a name="223774519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20closures/near/223774519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20closures.html#223774519">(Jan 23 2021 at 20:47)</a>:</h4>
<p>because the inner closure has <code>T</code> in its substs</p>



<a name="223774583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20closures/near/223774583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20closures.html#223774583">(Jan 23 2021 at 20:48)</a>:</h4>
<p>we probably want to look into closures during <code>AbstractConst</code> building</p>



<a name="223774601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20closures/near/223774601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20closures.html#223774601">(Jan 23 2021 at 20:49)</a>:</h4>
<p>or much rather, at the start of <code>AbstractConst</code> building to exit early with <code>Ok(None)</code> if we don't use any generic param.</p>



<a name="223774602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20closures/near/223774602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20closures.html#223774602">(Jan 23 2021 at 20:49)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="223899008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20closures/near/223899008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20closures.html#223899008">(Jan 25 2021 at 13:50)</a>:</h4>
<p>on stable</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">|</span><span class="n">x</span>: <span class="kt">u32</span><span class="o">|</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="p">}];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="223899080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20closures/near/223899080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20closures.html#223899080">(Jan 25 2021 at 13:51)</a>:</h4>
<p>its kind of weird that we/I use lazy norm to actually just mean "supplying the parent generics" here</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>